import 'package:base_flutter/base_flutter.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:ls_work/self_medicine/view_model/self_medicine_library_view_model.dart';
import 'package:ls_work/util/ext_utils.dart';

import '../../res/colors.dart';
class SelfMedicineLibraryPage extends BaseStatefulMvvmWidget{
  String? elderName;
  String? sexName;
  String? roomNo;
  dynamic customerId;


  SelfMedicineLibraryPage(
      {this.elderName, this.sexName, this.roomNo, this.customerId});

  @override
  State<StatefulWidget> createState() => _SelfMedicineLibraryState();
  
}

class _SelfMedicineLibraryState extends BaseMvvmListState<SelfMedicineLibraryViewModel,SelfMedicineLibraryPage>{
  @override
  Widget buildRootView(BuildContext context, Widget loadingContentWidget) {
    return Scaffold(
      backgroundColor: Colours.bg_color,
      appBar: AppBar(title: Text('药库明细'),),
      body: Column(
        children: [
          SizedBox(height: 12,),
          Row(
            crossAxisAlignment: CrossAxisAlignment.end,
            children: [
              Text(widget.elderName??"",style: TextStyle(fontSize: 17,fontWeight: FontWeight.bold,color: Colours.text_dark)),
              SizedBox(width: 10,),
              Text(widget.roomNo??""),
              SizedBox(width: 10,),
              Text(widget.sexName??"")
            ],
          ).addToContainer(
            decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: 4.borderRadius
            ),
            padding: EdgeInsets.symmetric(horizontal: 10,vertical: 12),
            margin: EdgeInsets.symmetric(horizontal: 16)
          ),
          
          loadingContentWidget.setWeight(1)
        ],
      ),
    );
  }

  @override
  Widget createItemWidget(int index) {
    var item = viewModel.listItems[index];
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        CommonText('商品名称：${item.medicineName??""}'),
        CommonText('品牌：${item.brand??""}'),
        CommonText('药品类型：${item.typeName??""}'),
        CommonText('大单位（数量）：${item.seniorDesc??""}'),
        CommonText('小单位（数量）：${item.juniorDesc??""}'),
        CommonText('合计：${item.totalMedicine??""}'),
        CommonText('预计服完时间：${(item.estimateRunoutDate??"").changeTime(format: [yyyy,'-',mm,'-',dd])}'),
      ].insertWidget(SizedBox(height: 8,)),
    ).addToContainer(
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: 6.borderRadius
      ),
      padding: EdgeInsets.symmetric(horizontal: 10,vertical: 12)
    );
  }

  @override
  EdgeInsets get listPadding => EdgeInsets.symmetric(horizontal: 16,vertical: 12);

  @override
  Widget get separatorDivider => SizedBox(height: 12,);

  @override
  SelfMedicineLibraryViewModel createViewModel() {
    return SelfMedicineLibraryViewModel(context,customerId: widget.customerId);
  }
  
}